package com.jlcindia;

public class Lab4 {

	public static void main(String[] args) {
		MethodParamService ref=new MethodParamService();
		System.out.println("=======PRIMITIVE======");
		int ab=123;
		System.out.println("In main before\t:"+ab);
		ref.modify(ab); // call by value
		System.out.println("In main after\t:"+ab);
		
		System.out.println("\n====REFERENCE====");
		User ur=new User();
		ur.phone=6579999L;
		System.out.println("In Main Before\t:"+ur.uid+"\t"+ur.phone);
		ref.modify(ur);
		System.out.println("In Main After\t:"+ur.uid+"\t"+ur.phone);
		System.out.println("\n");
		System.out.println("In Main Before\t:"+ur.uid+"\t"+ur.phone);
		ref.change(ur);
		System.out.println("In Main After\t:"+ur.uid+"\t"+ur.phone);

	}

}
class MethodParamService{
	void modify(int ab){
		System.out.println("--modifying--");
		System.out.println("Before Modifying\t:"+ab);
		ab=ab+1000;
		System.out.println("after Modifying\t:"+ab);
	}
	void modify(User user){
		System.out.println("--modify(User)--");
		System.out.println("Before Modifying\t:"+user.uid+"\t"+user.phone);
		user=new User();
		System.out.println("Before Modifying\t:"+user.uid+"\t"+user.phone);
		user.uid=user.uid+1000;
		user.phone=7795484339L;
		System.out.println("After Modifying\t:"+user.uid+"\t"+user.phone);
	}
	void change(User user){
		System.out.println("--change(User)--");
		System.out.println("Before Modifying\t:"+user.uid+"\t"+user.phone);
		user.uid=user.uid+1000;
		user.phone=9535065781L;
		System.out.println("After Modifying\t:"+user.uid+"\t"+user.phone);
		user=new User();
		user.uid=3232;
		user.phone=85858585L;
		System.out.println("After Modifying Ref\t:"+user.uid+"\t"+user.phone);
	}
}
class User{
	int uid;
	long phone;
}